package o;

import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

public final class aul extends aux {
    private static final Writer ˏ = new Writer() {
        public void write(char[] cArr, int i, int i2) {
            throw new AssertionError();
        }

        public void flush() throws IOException {
            throw new AssertionError();
        }

        public void close() throws IOException {
            throw new AssertionError();
        }
    };
    private static final atj ॱ = new atj("closed");
    private String ˊ;
    private ath ˋ = atl.ˎ;
    private final List<ath> ˎ = new ArrayList();

    public aul() {
        super(ˏ);
    }

    public ath ˋ() {
        if (this.ˎ.isEmpty()) {
            return this.ˋ;
        }
        throw new IllegalStateException("Expected one JSON element but was " + this.ˎ);
    }

    private ath ʻ() {
        return (ath) this.ˎ.get(this.ˎ.size() - 1);
    }

    private void ˏ(ath o_ath) {
        if (this.ˊ != null) {
            if (!o_ath.ॱॱ() || ʼ()) {
                ((atk) ʻ()).ˋ(this.ˊ, o_ath);
            }
            this.ˊ = null;
        } else if (this.ˎ.isEmpty()) {
            this.ˋ = o_ath;
        } else {
            ath ʻ = ʻ();
            if (ʻ instanceof atg) {
                ((atg) ʻ).ˎ(o_ath);
                return;
            }
            throw new IllegalStateException();
        }
    }

    public aux ˎ() throws IOException {
        ath o_atg = new atg();
        ˏ(o_atg);
        this.ˎ.add(o_atg);
        return this;
    }

    public aux ॱ() throws IOException {
        if (this.ˎ.isEmpty() || this.ˊ != null) {
            throw new IllegalStateException();
        } else if (ʻ() instanceof atg) {
            this.ˎ.remove(this.ˎ.size() - 1);
            return this;
        } else {
            throw new IllegalStateException();
        }
    }

    public aux ˊ() throws IOException {
        ath o_atk = new atk();
        ˏ(o_atk);
        this.ˎ.add(o_atk);
        return this;
    }

    public aux ˏ() throws IOException {
        if (this.ˎ.isEmpty() || this.ˊ != null) {
            throw new IllegalStateException();
        } else if (ʻ() instanceof atk) {
            this.ˎ.remove(this.ˎ.size() - 1);
            return this;
        } else {
            throw new IllegalStateException();
        }
    }

    public aux ॱ(String str) throws IOException {
        if (this.ˎ.isEmpty() || this.ˊ != null) {
            throw new IllegalStateException();
        } else if (ʻ() instanceof atk) {
            this.ˊ = str;
            return this;
        } else {
            throw new IllegalStateException();
        }
    }

    public aux ˊ(String str) throws IOException {
        if (str == null) {
            return ᐝ();
        }
        ˏ(new atj(str));
        return this;
    }

    public aux ᐝ() throws IOException {
        ˏ(atl.ˎ);
        return this;
    }

    public aux ˊ(boolean z) throws IOException {
        ˏ(new atj(Boolean.valueOf(z)));
        return this;
    }

    public aux ˏ(Boolean bool) throws IOException {
        if (bool == null) {
            return ᐝ();
        }
        ˏ(new atj(bool));
        return this;
    }

    public aux ˏ(long j) throws IOException {
        ˏ(new atj(Long.valueOf(j)));
        return this;
    }

    public aux ˏ(Number number) throws IOException {
        if (number == null) {
            return ᐝ();
        }
        if (!ॱॱ()) {
            double doubleValue = number.doubleValue();
            if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) {
                throw new IllegalArgumentException("JSON forbids NaN and infinities: " + number);
            }
        }
        ˏ(new atj(number));
        return this;
    }

    public void flush() throws IOException {
    }

    public void close() throws IOException {
        if (this.ˎ.isEmpty()) {
            this.ˎ.add(ॱ);
            return;
        }
        throw new IOException("Incomplete document");
    }
}
